package cn.alibab.cangku.controller;


import cn.alibab.cangku.service.ProductCategoryService;
import cn.alibab.cangku.service.ProductOutputService;
import cn.alibab.cangku.service.ProductService;
import cn.alibab.cangku.vo.ProductInputVo;
import cn.alibab.cangku.vo.ProductOutputVo;
import cn.alibab.common.model.R;
import org.springframework.web.bind.annotation.*;

/**
 * @author Xd
 * @create 2020-07-09 16:10
 */
@RestController
@RequestMapping("biz/pro")
@CrossOrigin
public class ProductController {
    private final ProductService productService;
    private final ProductOutputService productOutputService;
    private final ProductCategoryService productCategoryService;


    public ProductController(ProductService productService, ProductOutputService productOutputService, ProductCategoryService productCategoryService) {
        this.productService = productService;
        this.productOutputService = productOutputService;
        this.productCategoryService = productCategoryService;
    }
    //查询所有的产品库存
    @GetMapping("getAllProduct")
    public R getAllProduct(){
        return  productService.getAllProduct();
    }
    //根据物资分类查询产品库存
//    @GetMapping("getAllProduct")
//    public R getAllProductBy(){
//        return  productService.getAllProduct();
//    }
    //根据物资名称查询产品库存
    @GetMapping("getAllProductByName")
    public R getAllProductByName(String name){
        return  productService.getAllProductByName(name);
    }
    //查询所有的入库产品
    @GetMapping("getAllProductInput")
    public R getAllProductInput(){
        return  productService.getAllProductInput();
    }
    //根据入库单查询
    @GetMapping("getProductByInNum")
    public R getProductByInNum(String inNum){
        return  productService.getProductByInNum(inNum);
    }

    //物资入库
    @PostMapping
    public R addProductInPut(@RequestBody ProductInputVo productInputVo){
        return  productService.putProductInPut(productInputVo);
    }

    //物资出库
    @PostMapping("delProductStock")
    public R delProductStock(@RequestBody ProductOutputVo productOutputVo){
        return  productOutputService.delProductStock(productOutputVo);
    }

    //查询所有出库产品
    @GetMapping("getAllOutProduct")
    public R getAllOutProduct(){
        return  productOutputService.getAllOutProduct( );
    }

    //通过pName获取对应的物资库存
    @GetMapping("findProductStockByPName")
    public R findProductStockByPName(String pName){
        return productOutputService.findProductStockByPName(pName);
    }
    //物品分区管理一级分类
//    @GetMapping("findAllProductCategory")
//    public R findAllProductCategory(){
//        return productCategoryService.findAllProductCategory();
//    }
//    //物品分区管理二级分类
//    @GetMapping("findAllProductTwoCategory/{pid}")
//    public R findAllProductTwoCategory(@PathVariable("pid") Long pid){
//        System.out.println(pid);
//        return productCategoryService.findAllProductTwoCategory(pid);
//    }
//    //物品分区管理三级分类
//    @GetMapping("findAllProductThreeCategory/{pid}")
//    public R findAllProductThreeCategory(@PathVariable("pid") Long pid){
//        System.out.println(pid);
//        return productCategoryService.findAllProductTwoCategory(pid);
//    }
//    @GetMapping("getCategory")
//    public R getCategory(){
//        return productCategoryService.getCategory();
//    }
}
